package com.example.idachuappone.utils;

import android.content.Context;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.net.NetworkInfo.State;
import java.util.regex.Pattern;

public class CheckUtil {
    public static boolean isCellphone(String str) {
        return Pattern.compile("1[0-9]{10}").matcher(str).matches();
    }

    public static boolean isEmail(String strEmail) {
        return Pattern.compile("\\w+([-+.]\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*").matcher(strEmail).matches();
    }

    public static boolean checkNet(Context context) {
        ConnectivityManager connManager = (ConnectivityManager) context.getSystemService("connectivity");
        if (connManager != null) {
            NetworkInfo info = connManager.getActiveNetworkInfo();
            if (info != null && info.isConnected() && info.getState() == State.CONNECTED) {
                return true;
            }
        }
        return false;
    }
}
